var AppWebsiteView = function() {
	return this.setup();
};
AppWebsiteView.prototype.setup = function() {
	var b = this.topbar();
	var a = new Ext.form.FormPanel(
			{
				id : "AppWebsiteView",
				closable : true,
				url : __ctxPath + "/system/addAppWebsite.do",
				title : "网站设置",
				layout : "form",
				tbar : b,
				autoScroll : true,
				iconCls : "menu-website",
				reader : new Ext.data.JsonReader( {
					root : "result"
				}, [ {
					name : "websiteId",
					mapping : "websiteId"
				}, {
					name : "websiteName",
					mapping : "websiteName"
				}]),
				items : [
						{
							xtype : "hidden",
							name : "appWebsite.websiteId",
							id : "websiteId"
						},
						{
							xtype : "container",
							/*labelAlign : "top",
							border : false,
							style : "padding-left:10%;padding-right:10%",
							layout : "form",
							items : [
									{
										xtype : "textfield",
										fieldLabel : "网站名称",
										name : "appWebsite.websiteName",
										id : "websiteName",
										allowBlank : false
									}
									]*/
							layout : "hbox",
							layoutConfigs : {
								align : "middle"
							},
							defaults : {
								//margins : "0 2 "
								margins : {
											top : 2,
											right : 4,
											bottom : 2,
											left : 4
										}
							},
							height : 35,	
							items : [ {
								xtype : "label",
								text : "网站名称",
								width : 60
							}, {
								id : "websiteName",
								xtype : "textfield",
								name : "appWebsite.websiteName",
								allowBlank : false,
								width : 130
							}]	
						} ]
			});
	Ext.Ajax.request( {
		url : __ctxPath + "/system/checkCompany.do",
		success : function(d, f) {
			var e = Ext.util.JSON.decode(d.responseText);
			if (e.success) {
				a.form.load( {
					url : __ctxPath + "/system/listCompany.do",
					deferredRender : true,
					layoutOnTabChange : true,
					waitMsg : "正在载入数据...",
					success : function(g, h) {
						var j = h.result.data.companyLogo;
						var i = Ext.getCmp("LogoPanel");
						if (j != null && j != "" && j != "undefind"
								&& i.body != null) {
							i.body.update('<img src="' + __ctxPath
									+ "/attachFiles/" + j
									+ '"  width="100%" height="100%"/>');
						}
					},
					failure : function(g, h) {
						Ext.ux.Toast.msg("编辑", "载入失败");
					}
				});
			} else {
				Ext.ux.Toast.msg("提示", "还没填写公司信息");
			}
		},
		failure : function(d, e) {
		}
	});
	function c(f) {
		var d = Ext.getCmp("companyLogo");
		var g = Ext.getCmp("LogoPanel");
		d.setValue(f[0].filepath);
		g.body.update('<img src="' + __ctxPath + "/attachFiles/"
				+ f[0].filepath + '"  width="100%" height="100%"/>');
		var e = document.getElementById("CompanyLogo");
		e.src = __ctxPath + "/attachFiles/" + f[0].filepath;
	}
	return a;
};
AppWebsiteView.prototype.topbar = function() {
	var a = new Ext.Toolbar( {
		id : "CompanyTopBar",
		height : 30,
		bodyStyle : "text-align:left",
		items : []
	});
	if (isGranted("_CompanyEdit")) {
		a.add(new Ext.Button( {
			text : "提交",
			iconCls : "btn-save",
			handler : function() {
				var b = Ext.getCmp("AppWebsiteView");
				if (b.getForm().isValid()) {
					b.getForm().submit(
							{
								waitMsg : "正在修改公司信息",
								success : function(c, e) {
									Ext.ux.Toast.msg("操作信息", "公司信息保存成功！");
									var d = Ext.getCmp("companyName")
											.getValue();
									Ext.getCmp("toolbarCompanyName").setText(
											d + "办公协同管理系统");
								}
							});
				}
			}
		}));
	}
	a.add(new Ext.Button( {
		text : "关闭",
		iconCls : "btn-close",
		handler : function() {
			var b = Ext.getCmp("centerTabPanel");
			b.remove("AppWebsiteView");
		}
	}));
	return a;
};